#include<bits/stdc++.h>
using namespace std;
struct fl{
	int k , s , f, v;
};
queue<fl>q;
int main(){
	freopen("lift.in" , "r" , stdin);
	freopen("lift.out" , "w" , stdout);
	int n , a , b;
	fl lf[210];
	cin >> n >> a >> b;
	for(int i = 1 ;i <= n ; i++){
		cin >> lf[i].k;
		lf[i].f = i;
		lf[i].v = 0;
	}
	lf[a].s = 0;
	q.push(lf[a]);
	while(!q.empty()){
		int c , d;
		auto k = q.front();		
		q.pop();
		if(k.f == b){
			cout << k.s << endl;
			return 0;
		}
		
		c = k.f + k.k;
		d = k.f - k.k;
		if(c <= n && lf[c].v == 0){
			lf[c].s = k.s + 1;
			lf[c].v = 1;
			q.push(lf[c]);
		}
		if(d >= 1 && lf[d].v == 0){
			lf[d].s = k.s + 1;
			lf[d].v = 1;
			q.push(lf[d]);
		}
	}
	cout << "-1" << endl;
	return 0;
}
